jQuery(function(){
	bar();
	pie();
	gauge();
	line();
	earth();
});


function bar(){
	var echart=echarts.init(document.getElementById("bar"));
	$.ajax({
		type:"get",
		url:"dataJSON/welcome_bar_data.json",
		async:true,
		success:function(result){
			var title=result.title;
			var x=result.x;
			var y=result.y;
			var option = {
            tooltip: {},
            legend: {
                data:title
            },
            xAxis: {
                data: x
            },
            yAxis: {},
            series: [{
                name: '公司数量',
                type: 'bar',
                data: y
            }]
        };
        echart.setOption(option);
		},
		error:function(){
			layer.msg("请求服务器失败！");
		}
	});
	}






function pie(){
	var echart=echarts.init(document.getElementById("pie"));
	var option = {
		 tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        data:['北京','天津','上海','深圳','广州','厦门','重庆','黑龙江','浙江','西藏']
    },
    series: [
        {
            name:'公司数量',
            type:'pie',
            selectedMode: 'single',
            radius: [0, '30%'],

            label: {
                normal: {
                    position: 'inner'
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data:[
                {value:2, name:'首都', selected:true},
                {value:4, name:'北方城市'},
                {value:7, name:'南方城市'}
            ]
        },
        {
            name:'公司数量',
            type:'pie',
            radius: ['40%', '55%'],
            label: {
                normal: {
                    
                    backgroundColor: '#eee',
                    borderColor: '#aaa',
                    borderWidth: 1,
                    borderRadius: 4,
                    // shadowBlur:3,
                    // shadowOffsetX: 2,
                    // shadowOffsetY: 2,
                    // shadowColor: '#999',
                    // padding: [0, 7],
                    rich: {
                        a: {
                            color: '#999',
                            lineHeight: 22,
                            align: 'center'
                        },
                        // abg: {
                        //     backgroundColor: '#333',
                        //     width: '100%',
                        //     align: 'right',
                        //     height: 22,
                        //     borderRadius: [4, 4, 0, 0]
                        // },
                        hr: {
                            borderColor: '#aaa',
                            width: '100%',
                            borderWidth: 0.5,
                            height: 0
                        },
                        b: {
                            fontSize: 16,
                            lineHeight: 33
                        },
                        per: {
                            color: '#eee',
                            backgroundColor: '#334455',
                            padding: [2, 4],
                            borderRadius: 2
                        }
                    }
                }
            },
            data:[
                {value:2, name:'北京'},
                {value:1, name:'天津'},
                {value:2, name:'黑龙江'},
                {value:1, name:'大连'},
                {value:1, name:'上海'},
                {value:3, name:'广州'},
                {value:2, name:'深圳'},
                {value:1, name:'厦门'}
            ]
        }
    ]
};
		
		echart.setOption(option);
}



function gauge(){
	var echart= echarts.init(document.getElementById("gauge"));
	var option = {
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },
    legend: {
        data:['利润', '支出', '收入']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'value'
        }
    ],
    yAxis : [
        {
            type : 'category',
            axisTick : {show: false},
            data : ['北京','上海','天津','深圳','广州','厦门','杭州','南京','成都']
        }
    ],
    series : [
        {
            name:'利润',
            type:'bar',
            label: {
                normal: {
                    show: true,
                    position: 'inside'
                }
            },
            data:[200468, 170769, 240436, 244474, 203610, 279320, 217310, 229340, 334510]
        },
        {
            name:'收入',
            type:'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true
                }
            },
            data:[321560, 304852, 354684, 311174, 336590, 461450, 415820, 481680 ,415870]
        },
        {
            name:'支出',
            type:'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'left'
                }
            },
            data:[-120111, -132222, -113201, -132134, -123190, -212330, -222210, -131270, -221130]
        }
    ]
};
echart.setOption(option);
}

function line(){
	var echart=echarts.init(document.getElementById("line"));
	var option = {
    tooltip : {
        trigger: 'axis',
        
        axisPointer: {
            type: 'cross',
            label: {
                backgroundColor: '#6a7985'
            }
        }
    },
    legend: {
        data:['北京班次','上海班次','天津班次','深圳班次','广州班次','厦门班次','杭州班次','南昌班次','宁夏班次','成都班次','南京班次']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : ['周一','周二','周三','周四','周五','周六','周日']
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'宁夏班次',
            type:'line',
            stack: '次数',
            areaStyle: {},
            data:[1603, 1457, 1398, 1464, 1573, 1616, 1731]
        },
        {
            name:'南昌班次',
            type:'line',
            stack: '次数',
            areaStyle: {},
            data:[1897, 1756, 1684, 1846, 1964, 2019, 2046]
        },{
            name:'天津班次',
            type:'line',
            stack: '次数',
            areaStyle: {},
            data:[2078, 1962, 1897, 2034, 2097, 2173, 2286]
        },{
            name:'南京班次',
            type:'line',
            stack: '次数',
            areaStyle: {},
            data:[2267, 2150, 2174, 2217, 2280, 2340, 2460]
        },{
            name:'成都班次',
            type:'line',
            stack: '次数',
            areaStyle: {},
            data:[2468, 2347, 2196, 2283, 2379, 2591, 2743]
        },
        {
            name:'厦门班次',
            type:'line',
            stack: '总量',
            areaStyle: {},
            data:[2018, 2145, 2016, 2154, 2236, 2451, 2315]
        },
        {
            name:'北京班次',
            type:'line',
            stack: '总量',
            areaStyle: {},
            data:[2751, 2961, 2486, 2671, 2869, 3016, 3126]
        },
        {
            name:'上海班次',
            type:'line',
            stack: '总量',
            areaStyle: {},
            data:[2675, 2748, 2849, 2946, 2764, 2972, 2944]
        },
        {
            name:'深圳班次',
            type:'line',
            stack: '总量',
            areaStyle: {},
            data:[3496, 3754, 3666, 3555, 3444, 3777, 3999]
        },
        {
            name:'杭州班次',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[4764, 4666, 4555, 4777, 4888, 4999, 5100]
        },
        {
            name:'广州班次',
            type:'line',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            areaStyle: {normal: {}},
            data:[5810, 5740, 5880, 5935, 6048, 6194, 6244]
        }
    ]
};
echart.setOption(option);
}
function earth(){
    var echart=echarts.init(document.getElementById("earth"));
    var option = {
    xAxis: {},
    yAxis: {},
    series: [{
        symbolSize: 20,
        data: [
            [10.0, 8.04],
            [8.0, 6.95],
            [13.0, 7.58],
            [9.0, 8.81],
            [11.0, 8.33],
            [14.0, 9.96],
            [6.0, 7.24],
            [4.0, 4.26],
            [12.0, 10.84],
            [7.0, 4.82],
            [5.0, 5.68]
        ],
        type: 'scatter'
    }]
};
echart.setOption(option);
}